package org.luckyjourney.controller.booking;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.luckyjourney.entity.booking.Booking;
import org.luckyjourney.entity.booking.PsychologicalAppointmentRecords;
import org.luckyjourney.entity.booking.dto.BookingDTO;
import org.luckyjourney.entity.booking.vo.BookingVO;
import org.luckyjourney.entity.plan.AppointmentRecords;
import org.luckyjourney.entity.plan.dto.PlanDTO;
import org.luckyjourney.entity.plan.vo.AppointmentRecordsVO;
import org.luckyjourney.entity.plan.vo.PlanVO;
import org.luckyjourney.entity.plan.vo.PlanVOS;
import org.luckyjourney.service.booking.BookingService;
import org.luckyjourney.service.plan.AppointmentRecordsService;
import org.luckyjourney.service.plan.ConsultantsPlanService;
import org.luckyjourney.util.PageResult;
import org.luckyjourney.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping("/luckyjourney/booking")
@Api(tags = "预约")
@Slf4j
public class BookingController {


    @Autowired
    BookingService bookingService;

    @Autowired
    ConsultantsPlanService consultantsPlanService;

    @Autowired
    AppointmentRecordsService appointmentRecordsService;

    @PostMapping("/selectPlan")
    @ApiOperation("查看可预约的咨询师")
    public Result selectPlan(@RequestBody PlanDTO planDTO) {
        List<PlanVO> plan=bookingService.selectPlan(planDTO);
        return Result.success(plan);
    }


    @PostMapping("/insertClick")
    @ApiOperation("点击预约")
    public Result insertClick(@RequestBody Booking  booking) {
        BookingVO bookingVO = bookingService.insertClick(booking);
        return Result.success(bookingVO);
    }

    @PostMapping("/selectAppointmentForm")
    @ApiOperation("查看咨询师端预约表单")
    public Result selectPlan(@RequestBody AppointmentRecords appointmentRecords) {
        List<AppointmentRecordsVO> appointmentRecordsVO=appointmentRecordsService.selectPlan(appointmentRecords);
        return Result.success(appointmentRecordsVO);
    }

    @PostMapping("/select")
    @ApiOperation("查看已排班的")
    public Result<List<PlanVOS>>selectPage(@RequestBody PlanDTO planDTO) {
        log.info("查看已排班的列表");
        log.info("请求方式 Post");
        log.info("请求路径 plan/select");
        List<PlanVOS> result = consultantsPlanService.selectPage(planDTO);
        return Result.success(result);
    }



    @PostMapping("/insertPersonal")
    @ApiOperation("填写个人资料")
    public Result insertPersonal(@RequestBody List<PsychologicalAppointmentRecords> psychologicalAppointmentRecords) {
         bookingService.insertPersonal(psychologicalAppointmentRecords);
        return Result.success();

    }

    @PostMapping("/selectPersonal")
    @ApiOperation("查看预约记录")
    public Result selectPersonal(@RequestBody  Booking  booking) {
        BookingVO bookingVO=bookingService.selectPersonal(booking);
        return Result.success(bookingVO);
    }


    @PostMapping("/Page")
    @ApiOperation("预约记录列表")
    public Result selectPage(@RequestBody BookingDTO bookingDTO) {
        PageResult result =bookingService.selectPage(bookingDTO);
        return Result.success(result);

    }


}
